/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *  SRVConfiguration.h - iPhoneSRV console for Surveyor SRV-1 and SVS 
 *
 *  Created by Nick Kitchener.  Copyright (C) 2009  Surveyor Corporation 
 *            and Nick Kitchener.  All rights reserved.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details (www.gnu.org/licenses)
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#import "SRVUIConfiguration.h"

@implementation SRVUIConfiguration
@synthesize ipAddress, portNumberUART0, portNumberUART1, frameRate, cameraResolution, cameraCompression, autoResolution;

NSString *kIPAddressKey			= @"srv_ip_address";
NSString *kPortNumberUART0Key	= @"uart0_port_number";
NSString *kPortNumberUART1Key	= @"uart1_port_number";
NSString *kFrameRateKey			= @"frame_rate";
NSString *kCameraCompressionKey	= @"camera_compresion";
NSString *kCameraResolutionKey	= @"camera_resoltion";
NSString *kAutoResolutionKey	= @"auto_resolution";

-(id)init {
	if(self = [super init]) {
		ipAddress			= @"192.168.2.10";
		portNumberUART0		= 10001;
		portNumberUART1		= 10002;
		frameRate			= 20.0;
		cameraCompression	= 1;
		cameraResolution	= @"a";
		autoResolution		= NO;
	}
	return self;
}

-(void)loadApplicationPreferences {
	NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
	[userDefaults synchronize];
	
	NSString *defipAddress = [userDefaults stringForKey:kIPAddressKey];
	if( defipAddress!=nil )
		ipAddress = defipAddress;
	
	portNumberUART0 = [userDefaults integerForKey:kPortNumberUART0Key];
	portNumberUART1 = [userDefaults integerForKey:kPortNumberUART1Key];
	frameRate			= [userDefaults floatForKey:kFrameRateKey];
	cameraCompression	= [userDefaults integerForKey:kCameraCompressionKey];
	cameraResolution	= [userDefaults stringForKey:kCameraResolutionKey];
	autoResolution		= [userDefaults integerForKey:kAutoResolutionKey];	

	NSLog(@"application preferences: IP=%@, a=%i, b=%i", ipAddress, portNumberUART0, portNumberUART1);
}

@end
